﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace wpf.Triage.Convert
{
    public class CommStateConvert : IValueConverter
    {
        /// <summary>
        /// 多值转换方法选中  2022-02-21
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string[] parray = parameter.ToString().Split('|');
            if (value == null)
                return string.Empty;
            if (value.ToString().Equals(string.Empty))
            {
                return string.Empty;
            }
            for (int i = 0; i < parray.Length; i++)
            {
                var result = parray[i].Split(':');
                if (result.Length == 2)
                {
                    if (result[0].Equals(value.ToString()))
                    {
                        return result[1];
                    }
                }
            }
            return string.Empty;
        }
        /// <summary>
        /// 单纯实现接口  2022-02-21
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return string.Empty;
        }
    }
}
